<?php
namespace App\Tool\Admin;
//获取分类
class GetCate
{
    public function getTree($data, $cate_id = 0, $count = 0) {
        //声明静态局部变量
        static $rec = array();
        foreach ($data as $val) {
            if ($val['parent_id'] == $cate_id) {
                $val['count'] = $count;
                $rec[] = $val;
                //递归调用，判断当前分类下是否还有子类
                Self::getTree($data, $val['id'], $count + 1);
            }
        }
        return $rec;
    }
}